#include "tooltipeventhandler.hpp"

ToolTipEventHandler::ToolTipEventHandler(QObject *parent) :
    QObject(parent)
{
}


bool ToolTipEventHandler::eventFilter(QObject *obj, QEvent *event)
{
    if (event->type() == QEvent::ToolTip)
    {
	QHelpEvent *helpEvent = static_cast<QHelpEvent*>(event);

	emit tooltipRequested(new QPoint(helpEvent->pos()));
	return true;
    } else if (event->type() == QEvent::Wheel) {
	// Check if STRG has been pressed
	if (QApplication::keyboardModifiers() != Qt::ControlModifier)
	    return QObject::eventFilter(obj, event);

	QWheelEvent *wheelEvent = static_cast<QWheelEvent*>(event);

	int numDegrees = wheelEvent->delta() / 16;
	emit zoomEvent(numDegrees);
	return true;
    }

    return QObject::eventFilter(obj, event);
}
